<?php

namespace Buickwang\Calculator\Calculators;

use Buickwang\Calculator\Interfaces\CalculatorInterface;
use Buickwang\Calculator\Models\CalculatorModel;

class StraightLineDepreciation implements CalculatorInterface
{
    protected $name = '直线折旧法';
    public function run(CalculatorModel $model)
    {
        $use_years = $model->use_years;//使用年限
        $original_value = $model->original_value;//原值
        $residuals_rate = $model->residuals_rate;//残值率
        $month_price = $original_value * (1 - $residuals_rate) / $use_years / 12;//月折旧费
        return number_format($month_price,2);
    }

    public function getName()
    {
        return $this->name;
    }
}